﻿@model DAEProde.Tasks.ViewModels.ResultsViewModel

@{
    ViewBag.Title = "ViewTournamentResults";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Tabla General de la Fecha: @Model.MatchDate.Name</h2>

<h4>El puntaje es actualizado luego de que el administrador actualiza los resultados de cada partido.</h4>

<p>
    @Html.ActionLink("Ver Tabla General", "ViewTournamentResults", new { id = Model.Tournament.Id })
</p>

<table>
    <tr>
        <th>
            Nombre Usuario
        </th>
        <th>
            Aciertos
        </th>
    </tr>

    @foreach (var item in Model.Scores) {
        <tr>
            <td>
                @item.UserName
            </td>
            <td>
                @item.Score
            </td>
        </tr>
    }
</table>


@using (Html.BeginForm("ChangeMatchDate", "ViewResults"))
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Cambiar Fecha</legend>

        @Html.Hidden("id", Model.MatchDate.Tournament.Id)

        <div class="editor-label">
            @Html.LabelFor(m => m.MatchDate)
        </div>
        <div class="editor-field">
            <!-- Manually creating dropdown because ASP.NET MVC won't handle selected-value correctly, IMO -->
            <!-- This would be a good item for a helper, which is beyond the scope of this sample. -->
            <select name="fId">
                @foreach (var matchDate in Model.MatchDate.Tournament.MatchDates)
                {
                    <option value="@matchDate.Id" @(matchDate.Equals(Model.MatchDate) ? "selected=\"selected\"" : "")>@matchDate.Name - @matchDate.Date.ToShortDateString()</option>
                }
            </select>
            @Html.ValidationMessageFor(m => m.MatchDate)
        </div>

        <p>
            <input type="submit" value="Ver Fecha" />
        </p>
    </fieldset>
}


